package string;

public class Test_ArrayToString {
    /*
    需求：
        把数组中的数据按照指定格式拼接成一个字符串
     */
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6};
        String s = "{";
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                s = s + arr[i] + "}";
            } else {
                s = s + arr[i] + ",";
            }
        }
        System.out.println(s);


    }
}
